
import Vue from 'vue'

Vue.directive('timepicker', {
  twoWay: true,
  bind: function (el,binding,vm) {
    $(el)
      .datetimepicker({
      	format: 'yyyy-mm-dd',
	    language:'zh-CN',
	    autoclose: true,
	    minView:'3',
	    todayBtn:true
      })
      .on('changeDate', function (ev) {
        binding.value = this.value;
      })
  },
  update: function (value) {
    this.el.value = value
    $(this.el).datetimepicker('update')
  },
  unbind: function () {
    $(this.el).datetimepicker('remove')
  }
})